package com.djl.transaction;

import org.springframework.lang.NonNull;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionException;
import org.springframework.transaction.TransactionStatus;

public class TxStackHolderPlatformTransactionManager implements PlatformTransactionManager {
    private final PlatformTransactionManager platformTransactionManager;

    public TxStackHolderPlatformTransactionManager(PlatformTransactionManager platformTransactionManager) {
        this.platformTransactionManager = platformTransactionManager;
    }

    @Override
    @NonNull
    public TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException {
        return platformTransactionManager.getTransaction(definition);
    }


    @Override
    public void commit(@NonNull TransactionStatus status) throws TransactionException {
        platformTransactionManager.commit(status);
    }


    @Override
    public void rollback(@NonNull TransactionStatus status) throws TransactionException {
        platformTransactionManager.rollback(status);
    }

}
